/**
 * Created with Intellij IDEA.
 * Description;
 * User:墨琦
 * Data:2023-03-29
 * Time:22:11
 */
public class Text2 {
    private boolean isVaildChar(char ch) {
        if(Character.isDigit(ch) || Character.isLetter(ch)) {
            return true;
        }
        return false;
    }

    public boolean isPalindrome(String s) {
        s = s.toLowerCase();
        int left = 0;
        int right = s.length()-1;

        while(left < right) {
            while(left < right && !isVaildChar(s.charAt(left))) {
                left++;
            }
            while(left < right && !isVaildChar(s.charAt(right))) {
                right--;
            }

            if(s.charAt(left) != s.charAt(right)) {
                return false;
            }else {
                left++;
                right--;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        Text2 fw=new Text2();

        System.out.println(fw.isPalindrome(new String("QWEasdf")));
    }
}
